from selenium import webdriver
import time

from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.by import By

driver=webdriver.Edge()
driver.maximize_window()
driver.get('file:///C:/Users/HP/Desktop/%E5%BC%B9%E7%AA%97/alert.html')

#点击按钮
driver.find_element(By.ID,'button').click()
time.sleep(5)

alert=driver.switch_to.alert
alert.accept()
time.sleep(5)

